package hxy.bytecode.reflact.sql;

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectDBFactory {
    public static Connection getDBConnection() {
        Connection conn = null;
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            String url = "jdbc:mysql://cupb.top:3306/eric";
            String user = "eric";
            String password = "newpass";
            conn = DriverManager.getConnection(url, user, password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }

    public static void main(String[] args) {
        Connection dbConnection = ConnectDBFactory.getDBConnection();
        if (dbConnection != null) {
            System.out.println("连接成功");
        }
    }
}